<template>
    <div class="">
     <equipmentprofile class="h-full"
     :equipmentList="equipmentList"
     :equipmentLists="equipmentLists" />
    </div>
</template>
<script setup lang="ts">
import equipmentprofile from '@/views/large-data-screen/component/public/equipment-profile.vue'
import {getScreenoverview,} from '@/api/screen/largeData'
import img1 from '@/assets/screenimg/unity1.png';
import img2 from '@/assets/screenimg/unity3.png';
import img3 from '@/assets/screenimg/unity2.png';
import { emitter } from '@/utils/mitt'
const equipmentList = ref([
    {
        name: '设备总数',
        id: 1,
        img: img1,
        number: 0

    },
    {
        name: '即将到期',
        id: 2,
        img: img2,
        number: 0

    },
    {
        name: '已到期',
        id: 3,
        img: img3,
        number: 0

    }

])
const equipmentLists = ref([
    {
        name: '故障设备',
        id: 1,
        img: '',
        number: 0

    },
    {
        name: '离线设备',
        id: 2,
        img: '',
        number: 0

    },
    {
        name: '告警设备',
        id: 3,
        img: '',
        number: 0

    },
    {
        name: '正常设备',
        id: 4,
        img: '',
        number: 0

    }
])
const re = (data) => {
    getoverview()
}
onMounted(()=>{
     getoverview()
     emitter.on('alarmEventsUnit', re)
})
onBeforeUnmount(() => {
    emitter.off('alarmEventsUnit',re)
})
//设备概况
const getoverview = ()=>{
    getScreenoverview({    //  应用系统或建筑时候传参
        systematicId:'',
        buildingId:'',
    }).then(res=>{

        equipmentList.value[0].number = res.result.total   //  设备总数
        equipmentList.value[1].number = res.result.expire  //即将到期
        equipmentList.value[2].number = res.result.expired //  已经过期
        equipmentLists.value[0].number = res.result.fault  //故障
        equipmentLists.value[1].number = res.result.offLine //离线
        equipmentLists.value[2].number = res.result.alarm  //告警
        equipmentLists.value[3].number = res.result.normal  //正常
    })
}
</script>
<style scoped lang="scss"></style>
